package com.example.springboot.moduleone.controller;

import com.example.springboot.config.WebConstant;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author Administrator
 */
@Controller
@RequestMapping(value =  WebConstant.API_PATH + "/admin")
public class adminController {


    @GetMapping(value = "/loginCheck")
    public String login(){
        System.out.println("用户进入登录页面");
        return "login";   //没使用json返回，直接映射到自定义登录的页面
    }

    //登陆失败
    @GetMapping("/loginFail")
    @ResponseBody
    public String loginFail(){
        System.out.println("用户登录失败");
        return "fail";
    }

    @GetMapping("/index")
    public String index(){
        System.out.println("用户进入主页");
        return "index";
    }
    //判断是否登陆成功
    @PostMapping("/login")
    public String login(String username, String password){
        if("admin".equals(username) && "123456".equals(password)){
            return "redirect:/api/admin/index";
        }else{
            return "redirect:/api/admin/loginFail";
        }
    }









}
